package duijiangji;

import com.unicom.office.OfficeRenderHelper;
import com.unicom.office.config.OfficeConfig;
import com.unicom.office.impl.OfficeConfigForJSONorXML;
import com.unicom.office.impl.OfficeRuntimeImpl;
import com.unicom.office.impl.XlsxEasyBuilder;
import com.unicom.office.runtime.OfficeRuntime;

import java.io.File;
import java.util.HashMap;

public class main {
    static String templateRootPath = "test/对讲机/template/";
    static String resultRootPath = "test/对讲机/result/";
    static OfficeRuntime runtime = new OfficeRuntimeImpl();
    static OfficeConfig config = new OfficeConfigForJSONorXML(templateRootPath + "config.xml")
            .register(new WanFunc())
            .register(new Maolilv());
    static OfficeRenderHelper lsqrb = new OfficeRenderHelper(templateRootPath + "列收确认表-模板.xlsx", config, runtime).setBulider(new XlsxEasyBuilder());
    static OfficeRenderHelper qpgb = new OfficeRenderHelper(templateRootPath + "前评估表-模板.xlsx", config, runtime).setBulider(new XlsxEasyBuilder());
    static OfficeRenderHelper jsgfs = new OfficeRenderHelper(templateRootPath + "技术规范书-模板.docx", config, runtime);
    static OfficeRenderHelper psbg = new OfficeRenderHelper(templateRootPath + "评审报告-模板.xlsx", config, runtime).setBulider(new XlsxEasyBuilder());

    public static void main(String[] args) {
        p4();
    }

    static void p1(){
        HashMap<String, Object> map = new HashMap<String, Object>();
        String projectName = "秦皇岛市北戴河区疾病预防控制中心物联网公网对讲服务项目";

        map.put("projectName", projectName);
        map.put("companyName", "秦皇岛市北戴河区疾病预防控制中心");
        map.put("year", "2020");
        map.put("month", "5");
        map.put("num", "6");
        map.put("price", "700");
        map.put("maxCostPrice", "580");
        map.put("costPrice", "540");
        map.put("jifeiNum", "（暂无）");
        map.put("accountManager", "张春艳");
        map.put("projectLeader", "张春艳");

        renderLSQRB(projectName, map);
        renderPSBG(projectName, map);
        renderQPGB(projectName, map);
        renderJSGFS(projectName, map);
    }

    static void p2(){
        HashMap<String, Object> map = new HashMap<String, Object>();
        String projectName = "秦皇岛市抚宁区疾病预防控制中心物联网公网对讲服务项目";

        map.put("projectName", projectName);
        map.put("companyName", "秦皇岛市抚宁区疾病预防控制中心");
        map.put("year", "2020");
        map.put("month", "4");
        map.put("num", "11");
        map.put("price", "700");
        map.put("maxCostPrice", "580");
        map.put("costPrice", "540");
        map.put("jifeiNum", "（必填）");
        map.put("accountManager", "杨继伟");
        map.put("projectLeader", "杨继伟");

        renderLSQRB(projectName, map);
        renderPSBG(projectName, map);
        renderQPGB(projectName, map);
        renderJSGFS(projectName, map);
    }

    static void p3(){
        HashMap<String, Object> map = new HashMap<String, Object>();
        String projectName = "秦皇岛市新宝路桥工程有限公司物联网公网对讲服务项目";

        map.put("projectName", projectName);
        map.put("companyName", "秦皇岛市新宝路桥工程有限公司");
        map.put("year", "2020");
        map.put("month", "6");
        map.put("num", "7");
        map.put("price", "700");
        map.put("maxCostPrice", "580");
        map.put("costPrice", "540");
        map.put("jifeiNum", "（必填）");
        map.put("accountManager", "吴华");
        map.put("projectLeader", "吴华");

        renderLSQRB(projectName, map);
        renderPSBG(projectName, map);
        renderQPGB(projectName, map);
        renderJSGFS(projectName, map);
    }

    static void p4(){
        HashMap<String, Object> map = new HashMap<String, Object>();
        String projectName = "秦皇岛中德实业有限公司物联网公网对讲服务项目";

        map.put("projectName", projectName);
        map.put("companyName", "秦皇岛中德实业有限公司");
        map.put("year", "2020");
        map.put("month", "5");
        map.put("num", "3");
        map.put("price", "650");
        map.put("maxCostPrice", "550");
        map.put("costPrice", "540");
        map.put("jifeiNum", "（必填）");
        map.put("accountManager", "祖丽伟");
        map.put("projectLeader", "祖丽伟");

        renderLSQRB(projectName, map);
        renderPSBG(projectName, map);
        renderQPGB(projectName, map);
        renderJSGFS(projectName, map);
    }

    static void p5(){
        HashMap<String, Object> map = new HashMap<String, Object>();
        String projectName = "秦皇岛福电实业集团有限公司抚宁电力工程处物联网公网对讲服务项目";

        map.put("projectName", projectName);
        map.put("companyName", "秦皇岛福电实业集团有限公司抚宁电力工程处");
        map.put("year", "2020");
        map.put("month", "5");
        map.put("num", "14");
        map.put("price", "700");
        map.put("maxCostPrice", "580");
        map.put("costPrice", "540");
        map.put("jifeiNum", "（必填）");
        map.put("accountManager", "鲁文宝");
        map.put("projectLeader", "鲁文宝");

        renderLSQRB(projectName, map);
        renderPSBG(projectName, map);
        renderQPGB(projectName, map);
        renderJSGFS(projectName, map);
    }

    static void renderLSQRB(String projectName, HashMap<String, Object> data){
        String targetPath = resultRootPath + projectName;
        File file = new File(targetPath);
        if(!file.exists()){
            file.mkdirs();
        }
        lsqrb.render(data, targetPath + "/列收确认表-" + projectName + ".xlsx");
    }

    static void renderPSBG(String projectName, HashMap<String, Object> data){
        String targetPath = resultRootPath + projectName;
        File file = new File(targetPath);
        if(!file.exists()){
            file.mkdirs();
        }
        psbg.render(data, targetPath + "/评审报告-" + projectName + ".xlsx");
    }

    static void renderQPGB(String projectName, HashMap<String, Object> data){
        String targetPath = resultRootPath + projectName;
        File file = new File(targetPath);
        if(!file.exists()){
            file.mkdirs();
        }
        qpgb.render(data, targetPath + "/前评估表-" + projectName + ".xlsx");
    }

    static void renderJSGFS(String projectName, HashMap<String, Object> data){
        String targetPath = resultRootPath + projectName;
        File file = new File(targetPath);
        if(!file.exists()){
            file.mkdirs();
        }
        jsgfs.render(data, targetPath + "/技术规范书-" + projectName + ".docx");
    }
}
